/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.cratos.xxgram.platf.message;

import com.cratos.xxgram.platf.base.BaseEntity;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.Column;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;
import org.redkale.convert.ConvertColumn;
import org.redkale.convert.ConvertType;
import org.redkale.convert.json.JsonConvert;
import org.redkale.util.Comment;

/**
 * 离线消息记录
 * @author SquRab
 */
@Table(comment = "离线消息")
public class OfflineMsgRecord extends BaseEntity {
    
    @Id
    @Column(length = 64, comment = "fromid+'-'+targetid+'-'+create36time +'-' + receiverid" )
    private String offlinerecordid = "";
    
    @Column(length = 64, comment = "fromid+'-'+targetid+'-'+create36time")
    private String messageid = "";

    @Comment("当前操作用户名称")
    @Transient
    private String operatorUserName;
    
    @Comment("当前操作用户Id")
    @Transient
    private int operatorUserId;
    
    @Column(comment = "发送方ID  用户ID")
    private int fromid;

    @Column(comment = "接收方ID  用户ID  群ID")
    private int targetid;

    @Column(comment = "接收用户id 解决群聊中")
    private int receiverid;
     
    @Comment("系统消息")
    public  static final  short MSG_KIND_SYSTEM = 10;
    
    @Comment("单聊")
    public static final  short MSG_KIND_PRIVATE = 20;
    
    @Comment("群聊")
    public  static final  short MSG_KIND_GROUP = 30;
    
    @Comment("聊天室")
    public  static final  short MSG_KIND_CHATROOM = 40;
    
    @Comment("服务端发送成功")
    public static final short MSG_SEND_STATU_SUCCESS = 20;
    
    @Comment("服务端发送失败")
    public static final short MSG_SEND_STATU_FAIL = 10;
    
    @Column(comment = "消息分类 10 系统消息  20 单聊  30 群组消息 40 聊天室消息")
    private short msgkind;

    @Column(comment = "回执状态  10 未读  20 已读  60 撤回")
    private short status = 10;

    @Column(comment = "消息类型")
    private  short msgtype;

    @Column(length = 2048, updatable = false, comment = "消息内容")
    private String content;
    
    @Column(updatable = false, comment = "发送时间")
    private long createtime;

    @Column(comment = "读消息时间")
    private long readtime;

    @Transient
    @Comment("消息总数")
    private int total;
    
    @Transient
    @Comment("接收方用户ID")
    private  List<Integer> receiveIds = new ArrayList();

    @Transient
    private BaseContent contentObj;

    @Transient
    private long maxtime;
    
    @Transient
    private long mintime;

    public long getMaxtime() {
        return maxtime;
    }

    public void setMaxtime(long maxtime) {
        this.maxtime = maxtime;
    }

    public long getMintime() {
        return mintime;
    }

    public void setMintime(long mintime) {
        this.mintime = mintime;
    }
    
    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    
    @ConvertColumn(ignore = true, type = ConvertType.JSON)
    public String getOfflinerecordid() {
        return offlinerecordid;
    }

    public void setOfflinerecordid(String offlinerecordid) {
        this.offlinerecordid = offlinerecordid;
    }

    @ConvertColumn(ignore = true, type = ConvertType.JSON)
    public int getReceiverid() {
        return receiverid;
    }

    public void setReceiverid(int receiverid) {
        this.receiverid = receiverid;
    }
    
   
    public OfflineMsgRecord() {
    }
 
    
    @ConvertColumn(ignore = true, type = ConvertType.JSON)
    public String getOperatorUserName() {
        return operatorUserName;
    }

    public void setOperatorUserName(String operatorUserName) {
        this.operatorUserName = operatorUserName;
    }
   
    @ConvertColumn(ignore = true, type = ConvertType.JSON)
    public int getOperatorUserId() {
        return operatorUserId;
    }

    public void setOperatorUserId(int operatorUserId) {
        this.operatorUserId = operatorUserId;
    }
    
    @ConvertColumn(ignore = true, type = ConvertType.JSON)
    public BaseContent getContentObj() {
        return contentObj;
    }
    
    public void setContentObj(BaseContent contentObj) {
        this.contentObj = contentObj;
    }
    
    public void setMessageid(String messageid) {
        this.messageid = messageid;
    }
    
    @ConvertColumn(ignore = true, type = ConvertType.JSON)
    public List<Integer> getReceiveIds() {
        return receiveIds;
    }

    public void setReceiveIds(List<Integer> receiveIds) {
        this.receiveIds = receiveIds;
    }

    public String getMessageid() {
        return this.messageid;
    }

    public void setFromid(int fromid) {
        this.fromid = fromid;
    }

    public int getFromid() {
        return this.fromid;
    }

    public void setTargetid(int targetid) {
        this.targetid = targetid;
    }

    public int getTargetid() {
        return this.targetid;
    }

    public void setMsgkind(short msgkind) {
        this.msgkind = msgkind;
    }

    public short getMsgkind() {
        return this.msgkind;
    }

    public void setStatus(short status) {
        this.status = status;
    }

    public short getStatus() {
        return this.status;
    }

    public short getMsgtype() {
        return msgtype;
    }

    public void setMsgtype(short msgtype) {
        this.msgtype = msgtype;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public void setCreatetime(long createtime) {
        this.createtime = createtime;
    }
    
    public long getCreatetime() {
        return this.createtime;
    }

    public void setReadtime(long readtime) {
        this.readtime = readtime;
    }
    
    @ConvertColumn(ignore = true, type = ConvertType.JSON)
    public long getReadtime() {
        return this.readtime;
    }

    @Override
    public String toString() {
        return JsonConvert.root().convertTo(this);
    }
}
